home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / EGAVGA.SWG / 0005_Svga stuff.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  3.1 KB  |  139 lines

  1.  
  2. uses crt;
  3. {
  4.   Public Domain Code By David Henningsson 1996 (DIWIC)
  5.   Spread it and use it, if you like.
  6.   Written in Turbo Pascal 6.0
  7.   Warning: This stuff is very slow and inoptimal.
  8.   Do some "brain physics" and speed it up yourself!
  9. }
  10.  
  11.  
  12. const Svgatext:Array[0..4,0..15] of Byte = (
  13. (0,1,1,0,1,0,1,0,0,1,1,0,0,1,0,0),
  14. (1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0),
  15. (0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0),
  16. (0,0,1,0,1,1,1,0,1,0,1,0,1,0,1,0),
  17. (1,1,0,0,0,1,0,0,0,1,1,0,1,0,1,0));
  18.  
  19.  
  20. var Pro:Procedure;
  21.     CurBank:Byte;
  22.  
  23. { Only for 640x480x256 }
  24. Procedure PutVpixel(X,Y:Word;F:Byte); assembler;
  25. asm
  26.   mov ax,640
  27.   mul Y
  28.   add ax,X     { If this putpixel routine seems to skip parts of the screen }
  29.   adc dx,0     { or overwrites stuff already written }
  30.   mov bx,4096  { <- try changing this number (to another power of two) }
  31.   div bx   { This line is inoptimal... }
  32.   xchg ax,dx
  33.   push ax
  34.   cmp dl,CurBank
  35.   je @@DontSwitchBanks
  36.   mov CurBank,dl
  37.   mov ax,$4F05
  38.   mov bx,0
  39.   Call Pro
  40. @@DontSwitchBanks:
  41.   pop di
  42.   mov ax,0A000h
  43.   mov es,ax
  44.   mov al,F
  45.   stosb
  46. end;
  47.  
  48. { Goes a little bit faster, inline bank switching, only for Cirrus Logic }
  49. { Have tried to optimize it a bit }
  50. Procedure PutVpixel2(X,Y:Word;F:Byte); assembler;
  51. asm
  52.   mov ax,640
  53.   mul Y
  54.   add ax,X
  55.   adc dx,0
  56.   mov di,ax
  57.   mov ah,dl
  58.   shl ah,4
  59.   cmp ah,CurBank
  60.   je @@DontSwitchBanks
  61.   mov CurBank,ah
  62.   mov dx,$3CE
  63. {  in al,dx  }     { These four lines don't seem to be needed. If there is }
  64. {  mov bl,al }     { trouble, try putting them back in business.}
  65.   mov al,9
  66.   out dx,ax
  67. {  mov al,bl }
  68. {  out dx,al }
  69. @@DontSwitchBanks:
  70.   mov ax,0A000h
  71.   mov es,ax
  72.   mov al,F
  73.   stosb
  74. end;
  75.  
  76. var I,J:Integer;
  77.     K,L,M:Byte;
  78.     Pal:Array[0..255,1..3] of Byte;
  79.  
  80. begin
  81.   asm
  82.     mov ax,$4F02
  83.     mov bx,$101
  84.     int 10h     { Set SVGA mode: 640x480x256 }
  85.     mov ax,$4F01
  86.     mov cx,$101
  87.     push ds
  88.     pop es
  89.     mov di,OFFSET Pal
  90.     int 10h
  91.     mov di,OFFSET Pal+12
  92.     mov bx,[di]
  93.     mov cx,[di+2]
  94.     mov WORD [Pro],bx
  95.     mov WORD [Pro+2],cx  { Look up pointer to bank switcher }
  96.   end;
  97.   CurBank := 255; { Will always switch banks the first time }
  98.   Fillchar(Pal,Sizeof(Pal),0);
  99.   For I := 0 to 63 do begin
  100.     Pal[I,1] := I;
  101.     Pal[I+64,1] := 63-I;
  102.     Pal[I+64,2] := I;
  103.     Pal[I+128,2] := 63-I;
  104.     Pal[I+128,3] := I;
  105.     Pal[I+192,3] := 63-I;
  106.   end;
  107.   asm
  108.     cld
  109.     mov si,OFFSET Pal
  110.     mov cx,256*3
  111.     mov dx,$3C8
  112.     mov al,0
  113.     out dx,al
  114.     inc dx
  115.     rep outsb { Set palette }
  116.   end;
  117.  
  118. { K is random, since it is uninitialized! }
  119.   For J := 0 to 479 div 6 do begin
  120.     For I := 0 to 639 div 16 do begin
  121.       Inc(K);
  122.       For L := 0 to 4 do
  123.         For M := 0 to 15 do
  124.           If Svgatext[L,M] <> 0 then
  125.             PutVPixel(I*16+M,J*6+L,K); { Here is the inoptimal stuff lying }
  126.     end;
  127.     Dec(K,43);
  128.   end;
  129.   Directvideo := FALSE;
  130.   Textattr := 128;
  131.   WindMax := 30*256+80; { Sets up the CRT unit }
  132.   GotoXY(28,15);
  133.   Writeln('Is this SVGA or aint it?');
  134.   GotoXY(25,17);
  135.   Writeln('Is this 640x480x256 or aint it?');
  136.   REadkey;
  137.   Textmode(3);
  138. end.
  139.